#ifndef __CONCURRENT_MUTEX_HPP
#define __CONCURRENT_MUTEX_HPP
#include <pthread.h>
#include "common/uncopyable.hpp"

namespace concurrent {
  class Mutex : public common::Uncopyable {
  private:
    pthread_mutex_t mutex;

  public:
    Mutex() {
      pthread_mutex_init(&(this->mutex), NULL);
    }
    ~Mutex() {
      unlock();
    }
    void lock() {
      pthread_mutex_lock(&(this->mutex));
    }
    void unlock() {
      pthread_mutex_unlock(&(this->mutex));
    }
    bool try_lock();
  };
}// namespace concurrent

#endif
